#coding:utf-8
import requests
from bs4 import BeautifulSoup
import codecs

#简单爬虫

r = requests.get("http://read.qidian.com/hankread/2465506/6482008")

html_doc = r.content.decode('utf-8')
print type(html_doc)

f= codecs.open('E:/User/image/novel.html','w',encoding = 'utf-8')
f.write(html_doc)
f.close()

soup = BeautifulSoup(html_doc,'lxml')
chapters = soup.find_all(name='div',attrs = {"class":"main-text-wrap"})



f = codecs.open("E:/User/image/novel.txt","a",encoding = "utf-8")
for chapter in chapters:
    f.write(chapter.text)
f.close()





